import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Iterator;

import javax.swing.JComponent;


public class DotComponent extends JComponent implements MouseListener {	
	public static final int finger_size = 30;
	public static final int object_size = 60;
	public static final int table_size = 760;
	private DotGenerator dots;
	private int width = 640;
	private int height = 480;
	private float scale = 1.0f;
	private static final int NUMBER_OF_DOTS = 400;
	private int score = 0;
	public DotComponent(){
		this.dots = new DotGenerator(width, height);
		for (int i = 0; i<NUMBER_OF_DOTS; i++){
			dots.generateDot();
		}
	}
	public void setSize(int w , int h){
		width = w;
		height = h;
	}
	public void paint(Graphics g){
		updates(g);
	}
	public void updates(Graphics g){
		Graphics2D g2 = (Graphics2D)g;//SPECIAL LINE OF CODE FOR DRAWING ON SCREEEEEN
		g2.setColor(Color.BLACK);//graphics can only hold 1 color at a time
		g2.fillRect(0, 0, width, height);
		g2.setPaint(Color.MAGENTA);
		g2.drawString("Score: " + score,50,50);
		Iterator<Dot> iter = dots.gDots().iterator();
		while (iter.hasNext()){
			Dot curr = iter.next();
			g2.setColor(curr.gColor());
			g2.fill3DRect(curr.gX(), curr.gY(), curr.gsize(), curr.gsize(), false);
		}
	}
	public void mouseClicked(MouseEvent arg0) {
		dots = new DotGenerator(width, height);
		for (int i=0; i<NUMBER_OF_DOTS;i++){
			dots.generateDot();
		}
		repaint();
	}
	@Override
	public void mouseEntered(MouseEvent arg0) {
		
	}
	@Override
	public void mouseExited(MouseEvent arg0) {
		
	}
	@Override
	public void mousePressed(MouseEvent arg0) {
		
	}
	@Override
	public void mouseReleased(MouseEvent arg0) {
		
	} 
}